USE master
GO
EXEC master..sp_addlogin 'hongqp', '123456', 'master'
GO
EXEC master..sp_defaultdb @loginame= N'hongqp', @defdb = N'master'
GO
EXEC master..sp_addsrvrolemember @loginame='hongqp', @rolename='sysadmin'
GO

EXEC master..sp_addlogin 'QASS', '123456', 'IDP_SIMDB'
GO
EXEC master..sp_defaultdb @loginame= N'QASS', @defdb = N'IDP_SIMDB'
GO
USE [IDP_SIMDB]
GO
IF(EXISTS(SELECT *
FROM [QMIS].[dbo].[sysusers]
WHERE name = 'QASS'))
EXEC master..sp_revokedbaccess N'QASS'
EXEC master..sp_grantdbaccess @loginame = N'QASS', @name_in_db = N'QASS'
GO
USE [IDP_SIMDB]
GO
EXEC master..sp_addrolemember N'db_datareader', N'QASS'
GO
USE [QMIS]
GO
IF(EXISTS(SELECT *
FROM [QMIS].[dbo].[sysusers]
WHERE name = 'QASS'))
EXEC master..sp_revokedbaccess N'QASS'
GO
EXEC master..sp_grantdbaccess @loginame = N'QASS', @name_in_db = N'QASS'
GO
USE [QMIS]
GO
EXEC master..sp_addrolemember N'db_datareader', N'QASS'
GO
